/**
 * 根据数组中对象的某个字段,将数组排序
 * @param arr
 * arr = [{ key1: value1, key2: value2 }, ... ]
 * @param field
 * field = key1/key2
 * @returns []
 */
export const sortArray = <T, >(arr: T[], field: keyof T): T[] => {
  return arr.sort((a, b) => {
    return parseFloat(b[field] as string) - parseFloat(a[field] as string)
    // if (a[field] > b[field]) {
    //   return -1
    // }
    // if (a[field] < b[field]) {
    //   return 1
    // }
    // return 0
  })
}
